﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class View_AnswerMessage : System.Web.UI.Page
{
    AccessDAO dao = new AccessDAO();
    protected void Page_Load(object sender, EventArgs e)
    {
        IsAdmin.Admin();
        if (!Page.IsPostBack)
        {
            int id = Convert.ToInt32(Session["messageId"].ToString());
            string ss = "select * from messageInfo where id="+id;
            DataSet ds = dao.getDs(ss);
            foreach (DataRow dr in ds.Tables["message"].Rows)
            {
                this.lblName.Text = dr["messname"].ToString();
                this.lblSex.Text = dr["messsex"].ToString();
                this.lblphone.Text = dr["messtelep"].ToString();
                this.lblTime.Text = dr["messTime"].ToString();
                this.txtContent.Text = dr["content"].ToString();
                this.FCKeditor1.Value = dr["answer"].ToString();
            }
        }
    }
    //回复
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Session["messageId"].ToString());
        string answer = this.FCKeditor1.Value;
        string ss = "update messageInfo set answer='"+answer+"' where id="+id;

        if (!answer.Equals(""))
        {
            if (dao.getComm(ss)!= 0)
            {
                RegisterStartupScript("check", "<script language='javascript'>alert('回复成功');</script>");
                Server.Transfer("Message.aspx");
            }
            else
            {
                RegisterStartupScript("check", "<script language='javascript'>alert('回复失败');</script>");
            }
        }
        else
        {
            RegisterStartupScript("check", "<script language='javascript'>alert('请填写完整');</script>");
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Server.Transfer("Message.aspx");
    }
}
